<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layout 管理界面大布局示例 - Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://layui.org.cn/cdn.staticfile.org/layui/2.8.0/layui.js"></script>
  <script src="jquery.js" type="jscript"></script>
  <link href="https://layui.org.cn/cdn.staticfile.org/layui/2.8.0/css/layui.css" rel="stylesheet">
  <style>
    .friend-menu {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      background-color: #fff;
      border: 1px solid #ccc;
      padding: 10px;
      z-index: 999;
    }
  </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <div class="layui-logo layui-hide-xs layui-bg-black">布局示例</div>
    <!-- 头部区域（可配合layui 已有的水平导航） -->
    <ul class="layui-nav layui-layout-left">
      <!-- 移动端显示 -->
      <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
        <i class="layui-icon layui-icon-spread-left"></i>
      </li>
      <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">导航1</a></li>
      <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">导航2</a></li>
      <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">导航3</a></li>
      <li class="layui-nav-item">
        <a href="javascript:;">导航组</a>
        <dl class="layui-nav-child">
          <dd><a href="javascript:;">菜单11</a></dd>
          <dd><a href="javascript:;">菜单22</a></dd>
          <dd><a href="javascript:;">菜单33</a></dd>
        </dl>
      </li>
    </ul>
    <ul class="layui-nav layui-layout-right">
      <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
        <a href="javascript:;">
          <img src="https://unpkg.com/outeres@0.0.10/img/layui/icon-v2.png" class="layui-nav-img">
          测试者
        </a>
        <dl class="layui-nav-child">
          <dd><a href="javascript:;">个人信息</a></dd>
          <dd><a href="javascript:;">设置</a></dd>
          <dd><a href="javascript:;">退出</a></dd>
        </dl>
      </li>
      <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
        <a href="javascript:;">
          <i class="layui-icon layui-icon-more-vertical"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="layui-side layui-bg-black">
    <div class="layui-side-scroll">
      <ul class="layui-nav layui-nav-tree" lay-filter="test">
        <li class="layui-nav-item layui-nav-itemed">
          <a class="" href="javascript:;">好友</a>
          <dl class="layui-nav-child">
            <dd><a href="#" class="friend-link">好友1</a></dd>
            <dd><a href="javascript:;">好友2</a></dd>
            <dd><a href="javascript:;">好友3</a></dd>
            <dd><a href="javascript:;">好友4</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item">
          <a href="javascript:;">消息列表</a>
          <dl class="layui-nav-child">
            <dd><a href="javascript:;">列表1</a></dd>
            <dd><a href="javascript:;">列表2</a></dd>
            <dd><a href="javascript:;">超链接</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="javascript:;">朋友圈</a></li>
        <li class="layui-nav-item"><a href="javascript:;">删除/添加好友</a></li>
      </ul>
    </div>
  </div>
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
      <blockquote class="layui-elem-quote layui-text">
        Layui 框体布局内容主体区域
      </blockquote>
      <div class="layui-card layui-panel">
        <div class="layui-card-header">
          下面是充数内容，为的是出现滚动条
        </div>
        <div class="layui-card-body">
          充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>充数内容<br>你还真滑到了底部呀
        </div>
      </div>
      <br><br>
    </div>
  </div>
  <div class="layui-footer">
    <!-- 底部固定区域 -->
    底部固定区域
  </div>
</div>
<script>
  //JS
  layui.use(['element', 'layer', 'util'], function(){
    var element = layui.element;
    var layer = layui.layer;
    var $ = layui.$;

    // 事件委托，鼠标进入好友1标签时显示选项组
    $(document).on('mouseenter', '.friend-link', function() {
      var menu = $(this).next('.friend-menu');
      if (menu.is(':hidden')) {
        menu.show();
      }
    });

    // 事件委托，鼠标离开好友1标签时隐藏选项组
    $(document).on('mouseleave', '.friend-link', function() {
      var menu = $(this).next('.friend-menu');
      if (menu.is(':visible')) {
        menu.hide();
      }
    });

    // 点击页面其他位置隐藏选项组
    $(document).on('click', function() {
      $('.friend-menu').hide();
    });

    //头部事件
    element.on('nav(layui-layout-left)', function(elem){
      var navId = $(elem).attr('lay-id');
      switch(navId){
        case 'menuLeft':
          layer.msg('展开左侧菜单的操作', {icon: 0});
          break;
        default:
          break;
      }
    });

    element.on('nav(layui-layout-right)', function(elem){
      var navId = $(elem).attr('lay-id');
      switch(navId){
        case 'menuRight':
          layer.open({
            type: 1,
            title: '更多',
            content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
            area: ['260px', '100%'],
            offset: 'rt', //右上角
            anim: 'slideLeft',
            shadeClose: true,
            scrollbar: false
          });
          break;
        default:
          break;
      }
    });
  });
</script>
</body>
</html>
